#include<iostream>
#include<cstring>
using namespace std;
class number {
private:
	char num[9];
	char type;
public:
	number();
	number(char* n, char c);
	char* getnum();
	char gettype();
	~number();
};
number::number() {
	for (int i = 0; i < 9; i++) {
		num[i] = 0;
	}
	type = 'C';
}
number::number(char* n, char c) {
	for (int i = 0; i < strlen(n); i++) {
		num[i] = n[i];
	}
	num[strlen(n)] = 0;
	type = c;
}
number::~number() {
	for (int i = 0; i < 9; i++) {
		num[i] = 0;
	}
	type = 'C';
}
char* number::getnum() {
	return num;
}
char number::gettype() {
	return type;
}
class phone {
private:
	number* n = nullptr;
	int state;
	char name[21];
public:
	phone();
	phone(number N,int t,char*na);
	void print();
	bool find(char*na);
	~phone();
};
phone::phone() {
}
phone::phone(number N, int s, char* na){
	n = new number(N.getnum(), N.gettype());
	state = s;
	for (int i = 0; i < strlen(na); i++) {
		name[i] = na[i];
	}
	name[strlen(na)] = 0;
	cout << n->getnum() << " constructed." << endl;
}
phone::~phone() {
	cout << n->getnum() << " destructed." << endl;
}
void phone::print() {
		cout << "Phone=" << n->getnum() << "--Type=" << n->gettype() << "--State=";
		if (state == 1) {
			cout << "use";
		}
		else {
			cout << "unuse";
		}
		cout << "--Owner=" << name << endl;
}
bool phone::find(char*na) {
	if (strcmp(na, n->getnum()) == 0) {
		return true;
	}
	return false;
}
int main()
{
	char num[9];
	char type;
	int state;
	char name[21];
	cin >> num >> type >> state >> name;
	number a1(num, type);
	phone p1(a1, state, name);
	cin >> num >> type >> state >> name;
	number a2(num, type);
	phone p2(a2, state, name);
	cin >> num >> type >> state >> name;
	number a3(num, type);
	phone p3(a3, state, name);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		char nb[9];
		cin >> nb;
		int j = 0;
		if (p1.find(nb)) {
			j = 1;
		}
		else if (p2.find(nb)) {
			j = 2;
		}
		else if (p3.find(nb)) {
			j = 3;
		}
		if (j == 0) {
			cout << "wrong number." << endl;
		}
		else {
			if (j == 1) {
				p1.print();
			}
			else if (j == 2) {
				p2.print();
			}
			else if (j == 3) {
				p3.print();
			}
		}
	}

	return 0;
}